import * as mongoose from 'mongoose';

const ArticleSchema = new mongoose.Schema({
  title: String,
  content: String,
  category: [{ type: mongoose.SchemaTypes.ObjectId, ref: 'Category' }],
  author: { type: mongoose.SchemaTypes.ObjectId, ref: 'Author' }
});

// ArticleSchema.virtual('articles', {
//   ref: 'Article',
//   localField: '_id',
//   foreignField: 'category',
//   justOne: false,
// });

ArticleSchema.set('toObject', { getters: true, virtuals: true });
ArticleSchema.set('toJSON', { getters: true, virtuals: true });

// module.exports = {ArticleSchema}
export { ArticleSchema };
